package demo.velocity.util;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 示范工具类
 */
public class DemoUtils {
    /**
     * 这个有趣的小工具类返回了一条系统信息字符串,这里使用ver查看windows操作系统的版本
     * @return 系统信息字符串
     * @throws Exception 异常
     */
    public String getInfo() throws Exception {
        Runtime runtime = Runtime.getRuntime();
        Process p = runtime.exec("cmd.exe ver");
        InputStream inputStream = p.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        String line = bufferedReader.readLine();
        /*StringBuilder stringBuffer = new StringBuilder();
        while ((line = bufferedReader.readLine()) != null) {
            stringBuffer.append(line);
        }*/
        bufferedReader.close();
        inputStream.close();
        return line;
    }
}